<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- 防止反扒 -->
    <meta name="referrer" content="never">
    <link rel="stylesheet" href="./css/base.css">
    <script src="./js/common.js"></script>
    <script src="./datas/home.js"></script>
    <script src="./js/vue.js"></script>
    
    <link rel="import" href="./pages/HomePage.html">
    <link rel="import" href="./pages/FilmsPage.html">
    <link rel="import" href="./pages/DetailPage.html">

    <link rel="import" href="./components/TopBar.html">
    <link rel="import" href="./components/FilmList.html">
    <link rel="import" href="./components/FooterBox.html">
    <title>Document</title>
</head>

<body>
    <!-- 项目容器 start-->
    <div class="app">
        <!-- 头部搜索框 start -->
        <top-bar></top-bar>
        <!-- 头部搜索框 end -->
        <!-- 首页正文 start -->
        <div class="content-box">
            <!-- <home-page v-if=" pageName=='home' " @change-page=" changePage "></home-page> -->
            <!-- <home-page v-if=" pageName=='home' "></home-page>
            <film-page v-if=" pageName=='film' "></film-page>
            <detail-page v-if=" pageName=='detail' "></detail-page> -->
            <keep-alive>
                <component :is=" pageName "></component>
            </keep-alive>
        </div>
        <!-- 首页正文 end -->
        <footer-box v-if=" pageName=='DetailPage' "></footer-box>
    </div>
    <!-- 项目容器 end-->
</body>
<script>
    new Vue({
        el: ".app",
        data:{
            pageName:"HomePage"
        },
        methods: {
            changePage(name){
                console.log("父组件事件:",name);
                this.pageName = name;
            }
        },
        beforeMount() {
            this.$root.$on("changePage",(name)=>{
                this.pageName = name;
            })
        },
    })
</script>
</html>